﻿namespace Neovolve.Toolkit.UnitTests
{
    using System;
    using System.Collections.Generic;
    using System.Security.Principal;
    using FluentAssertions;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// The <see cref="ConversionExtensionsTests" />
    /// class tests the <see cref="ConversionExtensions" /> class.
    /// </summary>
    [TestClass]
    public class ConversionExtensionsTests
    {
        /// <summary>
        /// Runs test for to dictionary returns dictionary from dynamic type.
        /// </summary>
        [TestMethod]
        public void ToDictionaryReturnsDictionaryFromDynamicTypeTest()
        {
            var source = new
                             {
                                 First = "first",
                                 Second = 1234,
                                 Third = false,
                                 Fourth = Guid.NewGuid()
                             };

            IDictionary<String, Object> actual = source.ToDictionary();

            actual.Should().NotBeNull();
            actual["First"].Should().Be(source.First);
            actual["Second"].Should().Be(source.Second);
            actual["Third"].Should().Be(source.Third);
            actual["Fourth"].Should().Be(source.Fourth);
        }

        /// <summary>
        /// Runs test for to dictionary returns null when source is null.
        /// </summary>
        [TestMethod]
        public void ToDictionaryReturnsNullWhenSourceIsNullTest()
        {
            GenericIdentity source = null;

            IDictionary<String, Object> actual = source.ToDictionary();

            actual.Should().BeNull();
        }
    }
}
